package rainclass.shijuan2.gui;

import javax.swing.*;
import java.awt.*;

public class Widget {
    JFrame jFrame = new JFrame("231");
    JTextField jTextField1 = new JTextField();
    JTextField jTextField2 = new JTextField();
    JTextField jTextField3 = new JTextField();
    JTextArea jTextArea = new JTextArea();

    public void update(Student student){
        jTextField1.setText(student.getName());
        jTextField2.setText(String.valueOf(student.getEnglish()));
        jTextField3.setText(String.valueOf(student.getMath()));
        jTextArea.setText("姓名:"+student.getName()+"总成绩:"+ student.sum());
    }
    public void show(){
        jFrame.setLayout(new GridLayout(3,2,30,30));
        jFrame.add(jTextField1,jFrame);
        jFrame.add(jTextField2,jFrame);
        jFrame.add(jTextField3,jFrame);
        jFrame.add(jTextArea,jFrame);
        jFrame.setVisible(true);
        jFrame.setSize(900,500);
    }

    public static void main(String[] args) {
        Widget widget = new Widget();
        Student student = new Student("黎明",92,231);
        widget.show();
        widget.update(student);

    }

}
